import type { FileInfoDTO } from "../file/types";
import type { PageVO } from "../page-type";

export type QueryOrderVO = {
  orderNumber: string;
  orderStatus: string;
  customerCode: string;
  /**
   * 按产品
   */
  productCode: string;
  /**
   * 按联系电话
   */
  telephone: string;
  /**
   * 按联系人
   */
  contactor: string;
  /**
   * 按产品SN
   */
  productSn: string;
  /**
   * 按接收快递单号
   */
  receiveNumber: string;
  /**
   * 按返回快递单号
   */
  returnNumber: string;
  /**
   * 按付款状态
   */
  payState: string;
  /**
   * 按接收快递日期开始
   */
  receiveDateStart: string;
  /**
   * 按接收快递日期截止
   */
  receiveDateEnd: string;
  /**
   * 按工单创建日期开始
   */
  orderCreateDateStart: string;
  /**
   * 按工单创建日期截止
   */
  orderCreateDateEnd: string;
  /**
   * 按订单完成日期开始
   */
  orderCompleteDateStart: string;
  /**
   * 按订单完成日期截止
   */
  orderCompleteDateEnd: string;
  /**
   * 按创建人/检测人/维修人
   */
  createUserId: string;
} & PageVO

export type OrderViewDTO = {
  guid: string;
  orderNumber: string;
  customerName: string;
  contactor: string;
  telephone: string;
  orderStatus: string;
  cuser: string;
  ctime: string;
  checkEngineer: string;
  repairEngineer: string;
  productCount: number;
}

export const OrderStatusList = [{
  code: "SUBMITTED",
  name: "已提交"
}, {
  code: "PROCESSING",
  name: "处理中",
}, {
  code: "STOP",
  name: "已作废"
}, {
  code: "FINISHED",
  name: "已完成"
}]
export const OrderStatusEnum = {
  SUBMITTED: "SUBMITTED",
  PROCESSING: "PROCESSING",
  STOP: "STOP",
  FINISHED: "FINISHED"
}
export type OrderDTO = {
  guid: string,
  /**
   * 订单编号
   */
  orderNumber: string,
  /**
   * 客户id
   */
  customerCode: string,

  /**
   * 客户名称
   */
  customerName: string,

  /**
   * 站点名称
   */
  siteName: string,

  /**
   * 联系人
   */
  contactor: string,

  /**
   * 联系电话
   */
  telephone: string,

  /**
   * 地址
   */
  address: string,

  /**
   * 快递接受日期
   */
  receiveDate: string,

  /**
   * 快递接收单号
   */
  receiveNumber: string,

  /**
   * 工单状态
   */
  orderStatus: string,
  /**
   * 工单状态名称
   */
  orderStatusName: string,
  comment: string,
  cuserId: string,
  cuser: string,
  ctime: string,
  utserId: string,
  utser: string,
  utime: string,
}
export type OrderProductDTO = {
  guid: string,
  /**
   * 工单id
   */
  orderId: string,

  /**
   * 产品id
   */
  productCode: string,

  /**
   * 产品名称
   */
  productName: string,

  /**
   * 产品SN
   */
  productSn: string,
  /**
   * 产品维修状态编码
   */
  repairStateCode: string,
  /**
   * 产品维修状态
   */
  repairState: string,
  repairCount: number,
  shippingDate: string,
  comment: string,
  cuserId: string,
  cuser: string,
  ctime: string,
  utserId: string,
  utser: string,
  utime: string,
}
export type OrderProductCheckDTO = {
  guid: string,
  /**
   * 工单id
   */
  orderId: string,

  /**
   * 工单产品SN
   */
  productSn: string,
  /**
   * 客户故障描述
   */
  question: string,

  /**
   * 检测故障
   */
  questionCheck: string,
  /**
   * 质保状态编码
   */
  warrantyCode: string,
  /**
   * 质保状态
   */
  warranty: string,
  /**
   * 维修站点编码
   */
  repairSiteCode: string,
  /**
   * 维修站点
   */
  repairSite: string,
  workHourPrice: number,
  quoteState: string,
  quoteDate: string,
  isQuoteConfirm: boolean,
  quoteConfirmDate: string,
  cuserId: string,
  cuser: string,
  ctime: string,
}
export type OrderProductCheckPriceDTO = {
  guid: string,
  /**
   * 工单id
   */
  orderId: string,

  /**
   * 产品SN
   */
  productSn: string,

  /**
   * 产品备件id
   */
  productPartId: string,

  /**
   * 产品备件名称
   */
  productPartName: string,

  /**
   * 产品备件价格
   */
  price: number,

  /**
   * 数量
   */
  count: number,

  /**
   * 总价
   */
  totalPrice: number,
}
export type OrderProductRepairDTO = {
  guid: string,
  /**
   * 工单id
   */
  orderId: string,

  /**
   * 产品SN
   */
  productSn: string,

  /**
   * 支付状态
   */
  payState: string,

  /**
   * 支付日期
   */
  payDate: string,
  /**
   * 支付方式
   */
  payTypeCode: string,
  /**
   * 支付方式
   */
  payType: string,

  /**
   * 是否开票
   */
  isInvoice: boolean,
  /**
   * 开票类型
   */
  invoiceTypeCode: string,
  /**
   * 开票类型
   */
  invoiceType: string,

  /**
   * 发票编号
   */
  invoiceNumber: string,

  /**
   * 开票日期
   */
  invoiceDate: string,

  /**
   * 快递返回日期
   */
  returnDate: string,

  /**
   * 快递返回单号
   */
  returnNumber: string,
  /**
   * 产品维修状态编码
   */
  repairStateCode: string,
  /**
   * 维修状态
   */
  repairState: string,
  cuserId: string,
  cuser: string,
  ctime: string,
  utserId: string,
  utser: string,
  utime: string,
}
export type OrderDetailDTO = {
  /**
  * 工单基本信息
  */
  order: OrderDTO,
  /**
   * 产品列表
   */
  products: OrderProductDTO[],
  /**
   * 产品检修列表
   */
  productChecks: OrderProductCheckDTO[],
  /**
   * 产品检修配件列表
   */
  productCheckPrices: OrderProductCheckPriceDTO[],
  /**
   * 产品维修列表
   */
  productRepairs: OrderProductRepairDTO[],
  fileList: FileInfoDTO[]
}
export type CreateOrderVO = {
  guid: string;
  orderNumber: string;
  customerCode: string;
  customerName: string;
  siteName: string;
  contactor: string;
  telephone: string;
  address: string;
  receiveDate: string;
  receiveNumber: string;
  comment: string;
  products: CreateOrderProductVO[];
  files: string[];
}
export type CreateOrderProductVO = {
  guid: string;
  productCode: string;
  productName: string;
  productSn: string;
  comment: string;
}

export type OrderProductCheckPriceVO = {
  guid: string;
  productPartId: string;
  /**
  * 产品备件名称
  */
  productPartName: string;
  /**
   * 产品备件价格
   */
  price: number;
  /**
   * 数量
   */
  count: number;
  /**
   * 总价
   */
  totalPrice: number;
}

export type OrderProductCheckDetailDTO = {
  check: OrderProductCheckDTO,
  prices: OrderProductCheckPriceDTO[]
  fileIds: string[]
}

export type OrderProductCheckVO = {
  orderId: string;
  productSn: string;
  question: string;
  questionCheck: string;
  warrantyCode: string;
  warranty: string;
  repairSiteCode: string;
  repairSite: string;
  fileIdList: string[];
  prices: OrderProductCheckPriceVO[],
  workHourPrice: number,
  quoteState: string,
  quoteDate: string,
  isQuoteConfirm: boolean,
  quoteConfirmDate: string,
}

export type OrderProductRepairVO = {
  /**
   * 工单id
   */
  orderId: string,

  /**
   * 产品SN
   */
  productSn: string,

  /**
   * 支付状态
   */
  payState: string,

  /**
   * 支付日期
   */
  payDate: string,
  /**
   * 支付方式
   */
  payTypeCode: string,
  /**
   * 支付方式
   */
  payType: string,

  /**
   * 是否开票
   */
  isInvoice: boolean,
  /**
   * 开票类型
   */
  invoiceTypeCode: string,
  /**
   * 开票类型
   */
  invoiceType: string,

  /**
   * 发票编号
   */
  invoiceNumber: string,

  /**
   * 开票日期
   */
  invoiceDate: string,

  /**
   * 快递返回日期
   */
  returnDate: string,

  /**
   * 快递返回单号
   */
  returnNumber: string,
  /**
   * 产品维修状态编码
   */
  repairStateCode: string,
  /**
   * 维修状态
   */
  repairState: string,
}

export type OrderStatisticByDateDTO = {
  date: string,
  /**
   * 当日添加工单数量
   */
  createCount: number,
  /**
   * 当日接收快递数量
   */
  receiveCount: number,
  /**
   * 当日完成数量
   */
  completeCount: number
}


export type CustomerSearchDTO = {
  guid: string;
  receiveDate: string;
  receiveNumber: string;
  productName: string;
  productSn: string;
  repairState: string;
  repairSite: string;
  returnDate: string;
  returnNumber: string;
}
